﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Game6 : MonoBehaviour 
{
    public DianTi dianti;
    public GameObject curser;
    public GameObject AniReplayTrigger;
    public GameObject cameraRig;
    public Transform group5;
    public AudioClip dianTiAlarm;
    public AudioClip gongDiBG;
    public AudioClip dianTiGuanMen;
	void Start () 
	{
        curser.GetComponent<DistanceEvent>().OnNearEvent.AddListener(Player_OnNearCurser);

        AniReplayTrigger.GetComponent<DistanceEvent>().OnNearEvent.AddListener(Resume);
        SoundManager.instance.PlayBGMusic(gongDiBG);
	}


    /// <summary>
    /// 触碰到Curser
    /// </summary>
    private void Player_OnNearCurser()
    {
        dianti.PlayAnimation();
        curser.SetActive(false);
        Invoke("PauseAni", 7);
    }


    /// <summary>
    /// 暂停动画
    /// </summary>
    public void PauseAni()
    {
        dianti.PauseAnimation();
    }


    /// <summary>
    /// 继续播放
    /// </summary>
    public void Resume()
    {
        dianti.Resume();
        cameraRig.transform.SetParent(group5);
    }

}
